package com.xuexiang.xuidemo.page.uilts;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;

import com.xuexiang.xuidemo.ability.BaseStatusAbility;
import com.xuexiang.xuidemo.page.base.PageUtils;
import com.xuexiang.xuidemo.page.uilts.component.AnimationAbilitySlice;
import com.xuexiang.xuidemo.page.uilts.component.CustomWidgetAnimationAbilitySlice;
import com.xuexiang.xuidemo.page.uilts.component.WidgetAnimationAbilitySlice;
import com.xuexiang.xuidemo.page.uilts.component.WidgetPaddingAbilitySlice;

/**
 * 工具模块Pages
 *
 * @since 2021-03-23
 */
public class ToolsAbility extends BaseStatusAbility {
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setMainRoute(ColorUtilsAbilitySlice.class.getName());

        Class[] componentClzArray = new Class[]{
            // utils
            ColorUtilsAbilitySlice.class,
            DrawableUtilsAbilitySlice.class,
            KeyBoardUtilsAbilitySlice.class,
            SnackBarUtilsAbilitySlice.class,
            StatusBarUtilsAbilitySlice.class,
            ViewUtilsAbilitySlice.class,
            // utils.component
            WidgetAnimationAbilitySlice.class,
            WidgetPaddingAbilitySlice.class,
            AnimationAbilitySlice.class,
            CustomWidgetAnimationAbilitySlice.class
        };
        for (Class clz : componentClzArray) {
            addActionRoute(PageUtils.getAction(clz), clz.getName());
        }
    }

    /**
     * 跳转到该Ability页面
     *
     * @param ability 上下文
     * @param action 跳转路由
     */
    public static void start(Ability ability, String action) {
        Intent intent = new Intent();
        intent.setOperation(new Intent.OperationBuilder()
            .withBundleName(ability.getBundleName())
            .withAbilityName(ToolsAbility.class)
            .withAction(action)
            .build());
        ability.startAbility(intent);
    }
}
